home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / jkjoy / demo.frm (.txt) next >
Encoding:
Visual Basic Form  |  1998-05-30  |  9.0 KB  |  319 lines

  1. VERSION 5.00
  2. Object = "{F19117EA-F7D4-11D1-8500-D25A8F8C626C}#5.0#0"; "JKJoystick_Share.ocx"
  3. Begin VB.Form Form1 
  4.    BackColor       =   &H80000004&
  5.    Caption         =   "JK Joystick Control - Demo"
  6.    ClientHeight    =   4545
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   6210
  10.    ClipControls    =   0   'False
  11.    ControlBox      =   0   'False
  12.    DrawStyle       =   1  'Dash
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   4545
  15.    ScaleWidth      =   6210
  16.    StartUpPosition =   3  'Windows Default
  17.    Begin Joystick.JKJoystick JKJoystick1 
  18.       Left            =   3000
  19.       Top             =   3960
  20.       _ExtentX        =   847
  21.       _ExtentY        =   847
  22.    End
  23.    Begin VB.OptionButton Option1 
  24.       Caption         =   "3"
  25.       Height          =   255
  26.       Index           =   3
  27.       Left            =   4800
  28.       TabIndex        =   21
  29.       Top             =   3000
  30.       Width           =   1095
  31.    End
  32.    Begin VB.OptionButton Option1 
  33.       Caption         =   "2"
  34.       Height          =   255
  35.       Index           =   2
  36.       Left            =   4800
  37.       TabIndex        =   20
  38.       Top             =   2760
  39.       Width           =   1095
  40.    End
  41.    Begin VB.OptionButton Option1 
  42.       Caption         =   "1"
  43.       Height          =   255
  44.       Index           =   1
  45.       Left            =   4800
  46.       TabIndex        =   19
  47.       Top             =   2520
  48.       Width           =   1095
  49.    End
  50.    Begin VB.OptionButton Option1 
  51.       Caption         =   "0"
  52.       Height          =   255
  53.       Index           =   0
  54.       Left            =   4800
  55.       TabIndex        =   18
  56.       Top             =   2280
  57.       Value           =   -1  'True
  58.       Width           =   1095
  59.    End
  60.    Begin VB.CommandButton Command1 
  61.       Caption         =   "Test Joystick Port #0"
  62.       Height          =   375
  63.       Index           =   0
  64.       Left            =   2880
  65.       TabIndex        =   16
  66.       Top             =   1920
  67.       Width           =   1695
  68.    End
  69.    Begin VB.CommandButton Command1 
  70.       Caption         =   "Test Joystick Port #3"
  71.       Height          =   375
  72.       Index           =   3
  73.       Left            =   2880
  74.       TabIndex        =   15
  75.       Top             =   3360
  76.       Width           =   1695
  77.    End
  78.    Begin VB.CommandButton Command1 
  79.       Caption         =   "Test Joystick Port #2"
  80.       Height          =   375
  81.       Index           =   2
  82.       Left            =   2880
  83.       TabIndex        =   14
  84.       Top             =   2880
  85.       Width           =   1695
  86.    End
  87.    Begin VB.CommandButton Command1 
  88.       Caption         =   "Test Joystick Port #1"
  89.       Height          =   375
  90.       Index           =   1
  91.       Left            =   2880
  92.       TabIndex        =   13
  93.       Top             =   2400
  94.       Width           =   1695
  95.    End
  96.    Begin VB.PictureBox Picture3 
  97.       Height          =   2175
  98.       Left            =   2400
  99.       ScaleHeight     =   2115
  100.       ScaleWidth      =   195
  101.       TabIndex        =   10
  102.       Top             =   1920
  103.       Width           =   255
  104.       Begin VB.Line Line2 
  105.          BorderColor     =   &H000000FF&
  106.          BorderWidth     =   3
  107.          X1              =   0
  108.          X2              =   240
  109.          Y1              =   600
  110.          Y2              =   600
  111.       End
  112.    End
  113.    Begin VB.PictureBox Picture2 
  114.       Height          =   255
  115.       Left            =   120
  116.       ScaleHeight     =   195
  117.       ScaleWidth      =   2115
  118.       TabIndex        =   9
  119.       Top             =   4200
  120.       Width           =   2175
  121.       Begin VB.Line Line1 
  122.          BorderColor     =   &H000000FF&
  123.          BorderWidth     =   3
  124.          X1              =   240
  125.          X2              =   240
  126.          Y1              =   0
  127.          Y2              =   240
  128.       End
  129.    End
  130.    Begin VB.PictureBox Picture1 
  131.       Height          =   2175
  132.       Left            =   120
  133.       ScaleHeight     =   2115
  134.       ScaleWidth      =   2115
  135.       TabIndex        =   8
  136.       Top             =   1920
  137.       Width           =   2175
  138.       Begin VB.Shape Shape1 
  139.          Height          =   135
  140.          Left            =   720
  141.          Top             =   1080
  142.          Width           =   135
  143.       End
  144.    End
  145.    Begin VB.Label Label10 
  146.       Caption         =   "Middle"
  147.       Height          =   255
  148.       Left            =   4560
  149.       TabIndex        =   24
  150.       Top             =   960
  151.       Width           =   1455
  152.    End
  153.    Begin VB.Label Label9 
  154.       Caption         =   "Coolie hat position:"
  155.       Height          =   255
  156.       Left            =   4560
  157.       TabIndex        =   23
  158.       Top             =   720
  159.       Width           =   1575
  160.    End
  161.    Begin VB.Label Label8 
  162.       Caption         =   $"demo.frx":0000
  163.       Height          =   495
  164.       Left            =   120
  165.       TabIndex        =   22
  166.       Top             =   120
  167.       Width           =   6015
  168.    End
  169.    Begin VB.Label Label7 
  170.       Caption         =   "Current Port:"
  171.       Height          =   255
  172.       Left            =   4800
  173.       TabIndex        =   17
  174.       Top             =   1920
  175.       Width           =   975
  176.    End
  177.    Begin VB.Label Label6 
  178.       Caption         =   "(None)"
  179.       Height          =   255
  180.       Left            =   2880
  181.       TabIndex        =   12
  182.       Top             =   960
  183.       Width           =   2175
  184.    End
  185.    Begin VB.Label Label5 
  186.       Caption         =   "Buttons (last action):"
  187.       Height          =   255
  188.       Left            =   2880
  189.       TabIndex        =   11
  190.       Top             =   720
  191.       Width           =   2055
  192.    End
  193.    Begin VB.Label throttlest 
  194.       Caption         =   "Label8"
  195.       Height          =   255
  196.       Left            =   840
  197.       TabIndex        =   7
  198.       Top             =   1560
  199.       Width           =   1575
  200.    End
  201.    Begin VB.Label rudderst 
  202.       Caption         =   "Label7"
  203.       Height          =   255
  204.       Left            =   840
  205.       TabIndex        =   6
  206.       Top             =   1320
  207.       Width           =   975
  208.    End
  209.    Begin VB.Label yst 
  210.       Caption         =   "Label6"
  211.       Height          =   255
  212.       Left            =   840
  213.       TabIndex        =   5
  214.       Top             =   960
  215.       Width           =   1095
  216.    End
  217.    Begin VB.Label xst 
  218.       Caption         =   "Label5"
  219.       Height          =   255
  220.       Left            =   840
  221.       TabIndex        =   4
  222.       Top             =   720
  223.       Width           =   975
  224.    End
  225.    Begin VB.Label Label4 
  226.       Caption         =   "Throttle:"
  227.       Height          =   255
  228.       Left            =   120
  229.       TabIndex        =   3
  230.       Top             =   1560
  231.       Width           =   615
  232.    End
  233.    Begin VB.Label Label3 
  234.       Caption         =   "Rudder:"
  235.       Height          =   255
  236.       Left            =   120
  237.       TabIndex        =   2
  238.       Top             =   1320
  239.       Width           =   615
  240.    End
  241.    Begin VB.Label Label2 
  242.       Caption         =   "Y:"
  243.       Height          =   255
  244.       Left            =   120
  245.       TabIndex        =   1
  246.       Top             =   960
  247.       Width           =   255
  248.    End
  249.    Begin VB.Label Label1 
  250.       Caption         =   "X:"
  251.       Height          =   255
  252.       Left            =   120
  253.       TabIndex        =   0
  254.       Top             =   720
  255.       Width           =   135
  256.    End
  257. Attribute VB_Name = "Form1"
  258. Attribute VB_GlobalNameSpace = False
  259. Attribute VB_Creatable = False
  260. Attribute VB_PredeclaredId = True
  261. Attribute VB_Exposed = False
  262. Private Sub Command1_Click(Index As Integer)
  263. If JKJoystick1.TestStick(Index) = True Then
  264. MsgBox "Joystick on port " & Trim(Str(Index)) + " correctly connected!", , "JKJoystick"
  265. MsgBox "No Joystick on port " & Trim(Str(Index)) + " or not correctly connected!", , "JKJoystick"
  266. End If
  267. End Sub
  268. Private Sub Form_Load()
  269. JKJoystick1.TStart
  270. End Sub
  271. Private Sub JKJoystick1_ButtonPressed(ID As Integer)
  272. Label6 = "Button pressed: " & ID
  273. End Sub
  274. Private Sub JKJoystick1_ButtonReleased(ID As Integer)
  275. Label6 = "Button released: " & ID
  276. End Sub
  277. Private Sub JKJoystick1_CoolieChanged(NewCoolie As Integer)
  278. Select Case NewCoolie
  279. Case 0
  280. Label10 = "Middle"
  281. Case 1
  282. Label10 = "Up"
  283. Case 2
  284. Label10 = "Upper-right"
  285. Case 3
  286. Label10 = "Right"
  287. Case 4
  288. Label10 = "Lower-right"
  289. Case 5
  290. Label10 = "Down"
  291. Case 6
  292. Label10 = "Lower-left"
  293. Case 7
  294. Label10 = "Left"
  295. Case 8
  296. Label10 = "Upper-left"
  297. End Select
  298. End Sub
  299. Private Sub JKJoystick1_PosChange(NewX As Long, NewY As Long, NewThrottle As Long, NewRudder As Long)
  300. xst = NewX
  301. yst = NewY
  302. rudderst = NewRudder
  303. throttlest = NewThrottle
  304. Dim a
  305. Dim b
  306. a = (NewX / 72000) * Picture1.Width
  307. b = (NewY / 72000) * Picture1.Height
  308. Shape1.Move a, b
  309. a = (NewRudder / 69000) * Picture2.Width
  310. Line1.X1 = a
  311. Line1.X2 = a
  312. a = (NewThrottle / 69000) * Picture3.Height + 20
  313. Line2.Y1 = a
  314. Line2.Y2 = a
  315. End Sub
  316. Private Sub Option1_Click(Index As Integer)
  317. JKJoystick1.JoystickID = Index
  318. End Sub
  319.